<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class AdminLogMigrate extends AbstractMigration
{
    public function change()
    {
        $table = $this->table('admin_log', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_unicode_ci']);
        $table->addColumn('admin_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '管理员ID'])
            ->addColumn('action', 'string', ['limit' => 100, 'null' => false, 'comment' => '操作类型(格式:module.action)'])
            ->addColumn('content', 'text', ['null' => true, 'comment' => '操作内容'])
            ->addColumn('created_at', 'integer', ['signed' => false, 'null' => false, 'comment' => '创建时间'])
            ->addIndex(['admin_id'], ['name' => 'idx_admin_id'])
            ->addIndex(['action'], ['name' => 'idx_action'])
            ->addIndex(['created_at'], ['name' => 'idx_created_at'])
            ->create();
    }
}
